/*
学校正在做毕设项目，每名老师带领5个学生，总共有3名老师，需求如下

设计学生和老师的结构体，其中在老师的结构体中，有老师姓名和一个存放5名学生的数组作为成员

学生的成员有姓名、考试分数，创建数组存放3名老师，通过函数给每个老师及所带的学生赋值

最终打印出老师数据以及老师所带的学生数据。

*/

#include <iostream>

struct student
{
    std::string name;
    int score;
};

const int num_student = 5;
struct teacher
{
    std::string name;
    student students[num_student];
};

void print_student(const student *stu)
{
    std::cout << "****** Student ******" << std::endl;
    std::cout << "Name:\t" << stu->name << std::endl;
    std::cout << "Score:\t" << stu->score << std::endl;
}

void print_teacher(const teacher *tea)
{
    std::cout << "-------- Teacher ---------" << std::endl;
    std::cout << "Name:\t" << tea->name << std::endl;
    for (int i = 0; i < num_student; i++)
    {
        print_student(&tea->students[i]);
    }
}

void teach(teacher *tea, student students[])
{
    for (int i = 0; i < num_student; i++)
    {
        tea->students[i] = students[i];
    }
}

void teachers_info(const teacher *teachers, int N)
{
    for (int i = 0; i < N; i++)
    {
        print_teacher(&teachers[i]);
    }
}

int main(int argc, char const *argv[])
{
    const int num_teacher = 3;

    teacher teachers[num_teacher] = {
        {"Teacher1"},
        {"Teacher2"},
        {"Teacher3"}};

    student students1[num_student];
    for (int i = 0; i < num_student; i++)
    {
        students1[i] = {"student" + std::to_string(i + 10), 100 + i};
    }
    teach(&teachers[0], students1);

    student students2[num_student];
    for (int i = 0; i < num_student; i++)
    {
        students2[i] = {"student" + std::to_string(i + 20), 200 + i};
    }
    teach(&teachers[1], students2);

    student students3[num_student];
    for (int i = 0; i < num_student; i++)
    {
        students3[i] = {"student" + std::to_string(i + 30), 300 + i};
    }

    teach(&teachers[2], students3);

    teachers_info(teachers, num_teacher);

    return 0;
}
